package eg.backend.base.repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import javax.persistence.Query;

public interface BaseDao {
	<T> T save(T domainEntity);

	<T> void delete(T domainEntity);

	/**
	 * Retrieve the domain entity by identifier and class.
	 * 
	 * @param <T>
	 *            domain entity type
	 * @param <PK>
	 *            identifier type
	 * @param identifier
	 *            identifier of domain entity
	 * @param clazz
	 *            class of domain entity
	 * @return domain entity with this identifier in specific class
	 */
	<T, PK extends Serializable> T get(PK identifier, Class<T> clazz);

	<T> List<T> loadAll(Class<T> clazz);

	<T> T getByNamedQuery(String queryName, Map<String, Object> queryParams);

	<T> List<T> findByNamedQuery(String queryName, int limit,
			Map<String, Object> queryParams);
	
	<T> List<T> findRangeByNamedQuery(String queryName, int limit,
			Map<String, Object> queryParams, int start);
	
	int updateByNamedQuery(String queryName, Map<String, Object> queryParams);
	
	Query createQuery(String ql);
}
